#include<stdio.h>

int maxFunc(int n);
int minFunc(int n);
int Max(int a, int b, int c);
int Min(int a, int b, int c);
int Mid(int a, int b, int c);

int main()
{
    int n, k = 1; //k是序号
    scanf("%d", &n);
    while(maxFunc(n) - minFunc(n) != 495)
    {
        printf("%d: %d - %d = %d\n", k, maxFunc(n), minFunc(n), maxFunc(n) - minFunc(n));
        n = maxFunc(n) - minFunc(n);
        k++;
    }
    printf("%d: %d - %d = %d", k, maxFunc(n), minFunc(n), maxFunc(n) - minFunc(n));

    return 0;
}

int Max(int a, int b, int c)
{
    int m = a;
    if(b > m) m = b;
    if(c > m) m = c;
    return m;
}

int maxFunc(int n)
{
    int ge, shi, bai;
    int max, min, mid;
    ge = n % 10;
    bai = n / 100;
    shi = (n / 10) % 10;
    max = Max(ge, shi, bai);
    min = Min(ge, shi, bai);
    mid = Mid(ge, shi, bai);
    return 100 * max + 10 * mid + min;
}

int minFunc(int n)
{
    int ge, shi, bai;
    int max, min, mid;
    ge = n % 10;
    bai = n / 100;
    shi = (n / 10) % 10;
    max = Max(ge, shi, bai);
    min = Min(ge, shi, bai);
    mid = Mid(ge, shi, bai);
    return 100 * min + 10 * mid + max;
}

int Min(int a, int b, int c)
{
    int m = a;
    if(b < m) m = b;
    if(c < m) m = c;
    return m;
}

int Mid(int a, int b, int c)
{
    int max = a > b? a: b;
    max = max > c? max: c;
    int min = a < b? a: b;
    min = min < c? min: c;
    return a + b + c - max - min;
}